home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / vgradient.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-02-13  |  4.2 KB  |  151 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /* This file is part of the KDE project
  8.    Copyright (C) 2002, The Karbon Developers
  9.  
  10.    This library is free software; you can redistribute it and/or
  11.    modify it under the terms of the GNU Library General Public
  12.    License as published by the Free Software Foundation; either
  13.    version 2 of the License, or (at your option) any later version.
  14.  
  15.    This library is distributed in the hope that it will be useful,
  16.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.    Library General Public License for more details.
  19.  
  20.    You should have received a copy of the GNU Library General Public License
  21.    along with this library; see the file COPYING.LIB.  If not, write to
  22.    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23.    Boston, MA 02111-1307, USA.
  24. */
  25.  
  26. #ifndef __VGRADIENT_H__
  27. #define __VGRADIENT_H__
  28.  
  29. #include <QColor>
  30. #include <QList>
  31. #include <QMatrix>
  32.  
  33. #include "fpoint.h"
  34. #include "scribusapi.h"
  35.  
  36. class SCRIBUS_API VColorStop
  37. {
  38. public:
  39.     VColorStop( double r, double m, QColor c, double o, QString n, int s )
  40.     {
  41.         rampPoint = r;
  42.         midPoint = m; 
  43.         color = c;
  44.         opacity = o; 
  45.         name = n;
  46.         shade = s;
  47.     };
  48.     
  49.     VColorStop( const VColorStop& colorStop )
  50.     {
  51.         rampPoint = colorStop.rampPoint;
  52.         midPoint = colorStop.midPoint;
  53.         color = colorStop.color;
  54.         opacity = colorStop.opacity;
  55.         name = colorStop.name;
  56.         shade = colorStop.shade;
  57.     };
  58.  
  59.     QColor color;
  60.  
  61.     // relative position of color point (0.0-1.0):
  62.     double rampPoint;
  63.  
  64.     // relative position of midpoint (0.0-1.0)
  65.     // between two ramp points. ignored for last VColorStop.
  66.     double midPoint;
  67.     double opacity;
  68.     int shade;
  69.     QString name;
  70.     friend inline bool operator== ( VColorStop& s1, VColorStop& s2 )
  71.     { return s1.rampPoint == s2.rampPoint; };
  72. }
  73. ; // VColorStop
  74.  
  75. // comparison function for use with stable_sort
  76. bool compareStops( const VColorStop* item1, const VColorStop* item2 );
  77.  
  78. class SCRIBUS_API VGradient
  79. {
  80.     // friend class VGradientWidget;
  81.  
  82. public:
  83.     enum VGradientType
  84.     {
  85.         linear = 0,
  86.         radial = 1,
  87.         conic  = 2
  88.     };
  89.  
  90.     enum VGradientRepeatMethod
  91.     {
  92.         none    = 0,
  93.         reflect = 1,
  94.         repeat  = 2
  95.     };
  96.  
  97.     VGradient( VGradientType type = linear );
  98.     VGradient( const VGradient& gradient );
  99.     ~VGradient();
  100.  
  101.     VGradient& operator=(const VGradient& gradient);
  102.  
  103.     VGradientType type() const { return m_type; }
  104.     void setType( VGradientType type ) { m_type = type; }
  105.  
  106.     VGradientRepeatMethod repeatMethod() const { return m_repeatMethod; }
  107.     void setRepeatMethod( VGradientRepeatMethod repeatMethod ) { m_repeatMethod = repeatMethod; }
  108.  
  109.     const QList<VColorStop*>& colorStops() const;
  110.     void addStop( const VColorStop& colorStop );
  111.     void addStop( const QColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
  112.     void setStop( const QColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
  113.     void removeStop( VColorStop& colorStop );
  114.     void removeStop( uint n );
  115.     void clearStops();
  116.     uint Stops()  const { return m_colorStops.count(); }
  117.  
  118.     // This function let only one stop with offset value equal to 0 and 1.0
  119.     // by removing the firsts with 0.0 value and the lasts with 1.0 value;
  120.     void filterStops(void);
  121.  
  122.     FPoint origin() const { return m_origin; }
  123.     void setOrigin( const FPoint &origin ) { m_origin = origin; }
  124.  
  125.     FPoint focalPoint() const { return m_focalPoint; }
  126.     void setFocalPoint( const FPoint &focalPoint ) { m_focalPoint = focalPoint; }
  127.  
  128.     FPoint vector() const { return m_vector; }
  129.     void setVector( const FPoint &vector ) { m_vector = vector; }
  130.  
  131.     void transform( const QMatrix& m );
  132.  
  133. protected:
  134.     QList<VColorStop*>        m_colorStops;
  135.  
  136.     int  compareItems(const VColorStop* item1, const VColorStop* item2 ) const;
  137.     void inSort( VColorStop* d );
  138.  
  139. private:
  140.     VGradientType         m_type            : 2;
  141.     VGradientRepeatMethod m_repeatMethod    : 2;
  142.  
  143.     // coordinates:
  144.     FPoint m_origin;
  145.     FPoint m_focalPoint;
  146.     FPoint m_vector;
  147. }
  148. ; // VGradient
  149.  
  150. #endif /* __VGRADIENT_H__ */
  151.